import 'package:dark_notes/models/settingsmodel.dart';
import 'package:dark_notes/utilities/storage.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:dark_notes/pages/homepage.dart';
import 'package:dark_notes/models/notemodel.dart';

void main() {
  runApp(MultiProvider(providers: [
    ChangeNotifierProvider(
        create: (context) => NoteModel(storage: NoteStorage())),
    ChangeNotifierProvider(
        create: (context) => SettingsModel(storage: SettingsStorage())),
  ], child: MyApp()));
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return Consumer<SettingsModel>(builder: (context, settings, child) {
      return MaterialApp(
        title: '心雨笔记',
        theme: ThemeData(
          primaryColor: settings.isDarkTheme
              ? settings.darkPrimaryColor
              : settings.lightPrimaryColor,
          accentColor: settings.isDarkTheme
              ? settings.darkAccentColor
              : settings.lightAccentColor,
          brightness: settings.isDarkTheme ? Brightness.dark : Brightness.light,
        ),
        home: HomePage(),
      );
    });
  }
}
